using IM.Easy.Core.ServiceLifetime;
using IM.Easy.Core.Services;
using IM.Easy.Core.Utils;
using IM.Easy.Infrastructure.Query;
using IM.Easy.Entity.System;
using IM.Easy.SystemServices.Dtos;
using IM.Easy.SystemServices.Dtos.User;
using IM.Easy.SystemServices.Dtos.Role;

namespace IM.Easy.SystemServices.IServices
{
    public interface IRoleService : IAppServices<SysRole>
    {
        /// <summary>
        /// 创建一个新实体
        /// </summary>
        /// <param name="entity">要创建的实体</param>
        /// <returns>创建后的实体</returns>
        SysRole Create(SysRole entity);

        /// <summary>
        /// 根据 ID 获取实体
        /// </summary>
        /// <param name="id">实体的唯一标识</param>
        /// <returns>获取的实体</returns>
        SysRole GetById(long id);

        /// <summary>
        /// 通过角色编码获取角色信息
        /// </summary>
        /// <param name="code"></param>
        /// <returns></returns>
        SysRole GetByCode(string code);

        /// <summary>
        /// 获取所有实体
        /// </summary>
        /// <returns>所有实体的列表</returns>
        PageResponse<SysRole> GetPageList(SysRoleQueryDto query);

        /// <summary>
        /// 更新一个已有的实体
        /// </summary>
        /// <param name="entity">更新后的实体</param>
        /// <returns>更新后的实体</returns>
        bool UpdateRole(SysRole entity);

        /// <summary>
        /// 根据 ID 删除实体
        /// </summary>
        /// <param name="id">要删除的实体的唯一标识</param>
        /// <returns>操作是否成功</returns>
        bool DeleteRole(params long[] key);

        /// <summary>
        /// 根据角色获取用户
        /// </summary>
        PageResponse<UserDto> GetUsers(UserRoleQueryDto query);


        /// <summary>
        /// 获取不在某个角色中的用户
        /// </summary>
        PageResponse<UserDto> GetUsersNotIn(UserRoleQueryDto query);

        /// <summary>
        /// 为用户设置角色
        /// </summary>
        /// <param name="uid"></param>
        void SetRole(long roleId, params long[] uid);

        /// <summary>
        /// 取消用户的角色分配
        /// </summary>
        /// <param name="roleId">角色ID</param>
        /// <param name="uid">用户ID列表</param>
        void RemoveRole(long roleId, params long[] uid);
    }
}
